<template>
  <Content title="物料操作详情">
    <view class="device-details">
      <view class="content">
        <view class="main-box">
          <view class="info-box">
            <view class="title">
              <text class="txt u-line-1">设备编号:{{ data.deviceCode }} </text>
              <view class="tag-box"> </view>
            </view>
            <view class="text-box">
              <text class="label">工单号:</text>
              <text class="value">{{ id }}</text>
            </view>
            <!-- <view class="text-box">
              <text class="label">设备编号:</text>
              <text class="value">{{ data.deviceNo }}</text>
            </view> -->
            <view class="text-box">
              <text class="label">模具编号:</text>
              <text class="value">{{ data.moldCode }}</text>
            </view>
            <view class="text-box">
              <text class="label">模具名称:</text>
              <text class="value">{{ data.moldName }}</text>
            </view>
            <view class="text-box">
              <text class="label">产品编号:</text>
              <text class="value">{{ data.materialCode }}</text>
            </view>
            <view class="text-box">
              <text class="label">产品名称:</text>
              <text class="value">{{ data.materialName }}</text>
            </view>
            <view class="text-box">
              <text class="label">计划数量:</text>
              <text class="value">{{ data.planProduceQuantity }}</text>
            </view>
            <view class="text-box">
              <text class="label">生产数量:</text>
              <text class="value">{{ data.produceQuantity }}</text>
            </view>
          </view>
        </view>
      </view>

      <view class="btn-v">
        <view class="but-box">
          <u-button
            class="btn"
            type="primary"
            text="生产加料"
            @click="addProduction"
          ></u-button>
          <u-button
            class="btn"
            type="primary"
            text="生产退料"
            @click="delProduction"
          ></u-button>
          <u-button
            class="btn"
            type="primary"
            text="历史记录"
            @click="toPath"
          ></u-button>
          <!-- <u-button class="btn" type="primary" text="扫码加料"></u-button>
          <u-button class="btn" type="primary" text="扫码退料"></u-button> -->
        </view>
      </view>
    </view>
  </Content>
</template>

<script>
import Content from "@/components/content/index";
import fetch from "@/utils/fetch";
import { getNotice, setNotice } from "@/store/user.js";
import { setPageData } from "@/store/user";
export default {
  components: {
    Content,
  },
  data() {
    return {
      id: "",
      model: {},
      navIndex: 0,
      type: "1",
      data: {},
      fileList: [],
      shiftList: [],
      userList: [],
    };
  },
  onLoad: function (option) {
    //option为object类型，会序列化上个页面传递的参数
    this.id = option.workOrder;
  },
  onShow: function () {},
  onReady: function () {
    this.getList();
  },
  computed: {},
  mounted() {
    this.getList();
    // this.getShiftList();
    // this.getPersonList();//操作工列表
  },
  methods: {
    getColor(item2) {
      return item2 == "待排产"
        ? "#E5963A"
        : item2 == "已排产"
        ? "#998BF2"
        : item2 == "下发"
        ? "#6BBEE1"
        : item2 == "生产"
        ? "#73D8A6"
        : item2 == "中断"
        ? "#D48B3E"
        : item2 == "暂停"
        ? "#D8BE49"
        : item2 == "完成"
        ? "#4668E2"
        : item2 == "转产中"
        ? "#E794C9"
        : item2 == "转产完成"
        ? "#C25BC6"
        : item2 == "调机中"
        ? "#D8B2F2"
        : item2 == "调机完成"
        ? "#8698F6"
        : item2 == "拆模"
        ? "#EA709F"
        : "#31b099";
    },
    toPath() {
      uni.navigateTo({
        url:
          "/pages/staging/materials-handling/reporting-records?workOrder=" +
          this.id,
        animationType: "pop-in",
      });
    },
    getList() {
      fetch("get", "/dms/mobileEnd/getMaterialFindList", {
        workOrder: this.id,
      }).then((res) => {
        this.data = res.data;
      });
    },
    addProduction() {
      setPageData(this.data);
      uni.navigateTo({
        url: "/pages/staging/materials-handling/feeding",
      });
    },
    delProduction() {
      uni.navigateTo({
        url: "/pages/staging/materials-handling/material-return",
      });
    },
    submit() {
      fetch("post", "/dms/mobile/addReporting", {
        ...this.model,
        workCode: this.id,
      }).then((data) => {
        uni.$emit("openToast", {
          type: "success",
          title: "申请成功",
          complete() {
            uni.navigateBack({
              delta: 1,
            });
          },
        });
      });
    },
  },
};
</script>

<style scoped lang="scss">
.btn-v {
  display: flex;
  flex-direction: column;
}
.device-details {
  height: 100%;
  overflow: auto;
  padding-bottom: 150rpx;

  .content {
    min-height: 100%;
  }

  .title {
    font-size: 32rpx;
    margin-bottom: 20rpx;
    padding: 0 40rpx 20rpx 40rpx;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;

    .txt {
      flex: 1;
    }

    .tag-box {
      display: flex;
      align-items: center;
    }
  }

  .content-top {
    padding: 40rpx;

    .state {
      color: #f17a0a;
      margin-bottom: 20rpx;
    }
  }
  .search-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 60rpx;

    .label {
      margin: 0 20rpx;
    }
  }
}
.but-box {
  padding: 0 20px;
}
</style>
